| Conditions | 2 |
| Total Lines | 12 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import * as fs from 'fs' |
||
| 10 | |||
| 11 | export function processFileSync<T>( |
||
| 12 | filepath: string, |
||
| 13 | flags: string, |
||
| 14 | process: (fileDescriptor: number) => T |
||
| 15 | ) { |
||
| 16 | const fileDescriptor = fs.openSync(filepath, flags) |
||
| 17 | try { |
||
| 18 | return process(fileDescriptor) |
||
| 19 | } |
||
| 20 | finally { |
||
| 21 | fs.closeSync(fileDescriptor) |
||
| 22 | } |
||
| 67 | } |